coredump analyzer 神器, 没有之一. 您所在的位置:网站首页 分析dump文件 linux分析工具 coredump analyzer 神器, 没有之一.

coredump analyzer 神器, 没有之一.

2024-06-09 23:18| 来源: 网络整理| 查看: 265

(本文链接:http://blog.csdn.net/xiaoyanghuaban/article/details/46493861)

每天分析那些coredump文件,恨不得自己写一个这样的分析软件,可是自己能力有限.

终于发现了这个工具,堪称神作,.

自己去看哈,   传送门: http://core-analyzer.sourceforge.net/index.html 

我只是搬运者,感谢工具作者!

主要功能(其实就是一句话,任何分配的内存,尽收眼底)

Heap

· Scan heap and report memory corruption and memory usage statistics

· Display the layout of memory blocks surrounding a given address

· Display the memory block status containing a given address

· Show top heap memory blocks with biggest size (potential memory hog)

Reference

· Find the memory object’s size, type and symbol associated with a given address

· Search and report all references to a given object with any levels of indirection

Others

· Find all object instances of a given C++ class

· Display objects shared by selected or all threads

· Display disassembled instructions annotated with data object  context

· Data pattern within a range of memory region

· Detail process map including all segments and their attributes

如果想理解堆内存组织结构,也可以参考他的文章:   

http://core-analyzer.sourceforge.net/index_files/Page335.html

(其实,淘宝的人也写过一个关于堆内存分配的文章,自己google一下吧)

linux

The advantage of Core analyzer is its ability to parse heap memory into millions of individual memory blocks, which are allocated to application by heap memory manager. Only with this knowledge can Core Analyzer check memory corruption and search for object references. Users are encouraged to understand the basic heap data structures in order to maximize the benefits of the tool and develop your own support of custom memory manager if necessary.

I will briefly illustrate the data structures used by Linux/Windows/Mac OS system runtime memory managers. They are either open sourced or reverse engineered. You can find more detail in the source files of the project, Linux kernel source or from numerous on-line websites. Since OS vendors may change the implementation for each new version, this description may differ from what you are using. In all figures below, shaded areas represent heap data structures and blank areas are user space.

 

1. Ptmalloc

This is the memory manager used by GNU C library on Linux. The library glibc has a global “struct malloc_state” object, named main_arena, which is the root of all managed heap memory.

Arena is a logic collection of memory regions which are illustrated by various colored outlines. An arena could serve one memory request at a time. If there are multiple requests at the same time, ptmalloc would use other arenas to fulfill the requests simultaneously. If no arena is immediately available, new arena is created. Heap is  a single contiguous memory region which consists of user memory blocks. An arena may have one or more arenas at any time.

The difference between the main arena and a dynamically created arena is how they acquire memory from kernel. Main arena callssbrk() which usually starts immediately after the executable’s data section. On the other hand, a dynamic arena usesmmap() with fixed size, e.g. 64MB, and make sure the starting address is also aligned on the multiple of the size. If the first heap is used up, a new fix-sized heap is mmap-ed, which links to the dynamic arena’s heap data “strcut malloc_state”.

If the user’s request exceeds a threshold, e.g. 128KB, which may be changed dynamically, ptmalloc callsmmap() to allocate the memory andmunmap() when it is freed. This class of memory blocks is not linked by any heap data.

Each memory block on a heap is managed by a “struct malloc_chunk”, boundary tag. We can easily walk the heap as a link list with each tag as the offset to the next memory block.

    struct malloc_chunk {

        INTERNAL_SIZE_T prev_size;

        INTERNAL_SIZE_T size;

        struct malloc_chunk* fd;

        struct malloc_chunk* bk;

    };

 

Depending on whether a block and its previous and next blocks are free or in-use, some data fields of the structure are not used and may be part of the user space. Data in shaded area are heap data and belong to ptmalloc. If overwritten by application, it is typical heap data corruption.



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有